<template>
  <div class="app-container">
    <el-form :model="searchForm" label-width="80px" @keyup.enter.native="search()">
      <el-row>
        <!--<el-col class="other">-->
          <!--<el-form-item label="部门名称" size="small">-->
            <!--<el-input v-model="searchForm.teamName"></el-input>-->
          <!--</el-form-item>-->
        <!--</el-col>-->
        <el-col class="singleDatePicker">
          <el-form-item label="结算月份" size="small">
            <el-date-picker
              v-model="searchForm.tenementMonth"
              type="month"
              value-format="timestamp"
              placeholder="选择日期"
            >
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col class="searchBtn">
          <el-form-item size="small">
            <el-button type="primary" icon="el-icon-search" @click="search()">搜索</el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div class="table-btn">
      <el-button type="primary" size="small" icon="el-icon-plus" @click="addTeam()">添加</el-button>
      <el-dialog :title="dialogTitle" :visible.sync="outerVisible" width="900px">
        <el-form ref="teamRow" :rules="rules" :model="teamRow" label-width="100px">
          <el-row>
            <el-form-item label="房租计算方式" size="small" v-if="dialogType===1">
              <el-select v-model="teamRow.type" placeholder="请选择">
                <el-option
                  v-for="item in typeList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-col class="other">
              <el-form-item label="楼层(F)" size="small" class="item-inline">
                <el-autocomplete
                  v-model="teamRow.floorName"
                  :fetch-suggestions="querySearchFloor"
                  @select="handleSelectFloor"
                  placeholder="请输入内容"
                >
                </el-autocomplete>
              </el-form-item>
              <el-form-item label="部门人数" size="small">
                <el-input type="number" v-model.number="teamRow.teamCount"></el-input>
              </el-form-item>
              <el-form-item label="部门面积" size="small">
                <el-input type="number" v-model.number="teamRow.departmentArea"
                          :disabled="dialogType==1&&teamRow.type!==3">
                  <span slot="suffix">㎡</span>
                </el-input>
              </el-form-item>
              <el-form-item label="房租部门费用" size="small">
                <el-input type="number" v-model.number="teamRow.rentTeamPrice" v-if="dialogType!==1">
                  <span slot="suffix">元</span>
                </el-input>
              </el-form-item>
              <el-form-item label="物业费单价" size="small">
                {{teamRow.tenementPrice}}元
              </el-form-item>
              <el-form-item label="能耗单价" size="small">
                {{teamRow.energyPrice}}元
              </el-form-item>
              <el-form-item label="空调单价" size="small">
                {{teamRow.vrvPrice}}元
              </el-form-item>
              <el-form-item label="水单价" size="small">
                {{teamRow.waterPrice}}元
              </el-form-item>
              <el-form-item label="照明电费单价" size="small">
                {{teamRow.illuminationPrice}}元
              </el-form-item>
              <el-form-item label="公摊" size="small">
                <el-input type="number" v-model.number="teamRow.pooled">
                  <span slot="suffix">元</span>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col class="other">
              <el-form-item prop="teamName" label="部门/所" size="small" class="item-inline">
                <el-autocomplete
                  v-model="teamRow.teamName"
                  :fetch-suggestions="querySearchTeam"
                  @select="handleSelectTeam"
                  placeholder="请输入内容"
                >
                </el-autocomplete>
              </el-form-item>
              <el-form-item label="总人数" size="small">
                <el-input type="number" v-model.number="teamRow.peopleCount"></el-input>
              </el-form-item>
              <el-form-item label="总面积" size="small">
                {{teamRow.companyArea}}㎡
              </el-form-item>
              <el-form-item label="房租总费用" size="small">
                {{teamRow.rentPrice}}元
              </el-form-item>
              <el-form-item label="物业费费用" size="small">
                <el-input type="number" v-model.number="teamRow.tenementMonthPrice">
                  <span slot="suffix">元</span>
                </el-input>
              </el-form-item>
              <el-form-item label="能耗费用" size="small">
                <el-input type="number" v-model.number="teamRow.energyMonthPrice">
                  <span slot="suffix">元</span>
                </el-input>
              </el-form-item>
              <el-form-item label="空调费用" size="small">
                <el-input type="number" v-model.number="teamRow.vrvMonthPrice">
                  <span slot="suffix">元</span>
                </el-input>
              </el-form-item>
              <el-form-item label="水费用" size="small">
                <el-input type="number" v-model.number="teamRow.waterMonthPrice">
                  <span slot="suffix">元</span>
                </el-input>
              </el-form-item>
              <el-form-item label="照明电费费用" size="small">
                <el-input type="number" v-model.number="teamRow.illuminationMonthPrice">
                  <span slot="suffix">元</span>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col class="other">
              <el-form-item label="结算月份" size="small">
                <el-date-picker
                  v-model="teamRow.tenementMonth"
                  type="date"
                  value-format="timestamp"
                  placeholder="选择日期"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-form-item label="11楼房租核算" size="small">
            </el-form-item>
            <el-col class="other">
              <el-form-item label="单间单价" size="small">
                {{teamRow.roomPrice}}
              </el-form-item>
              <el-form-item label="工位单价" size="small">
                {{teamRow.stationPrice}}
              </el-form-item>
              <el-form-item label="合计" size="small" v-if="dialogType===0">
                <el-input type="number" v-model.number="teamRow.rentTotal">
                  <span slot="suffix">元</span>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col class="other">
              <el-form-item label="数量" size="small">
                <el-input type="number" v-model.number="teamRow.roomCount" :disabled="dialogType==1&&teamRow.type!==1">
                </el-input>
              </el-form-item>
              <el-form-item label="数量" size="small">
                <el-input type="number" v-model.number="teamRow.stationCount"
                          :disabled="dialogType==1&&teamRow.type!==1">
                </el-input>
              </el-form-item>
            </el-col>
            <el-col class="other">
              <el-form-item label="小计" size="small" v-if="dialogType===0">
                <el-input type="number" v-model.number="teamRow.roomSubtotal">
                  <span slot="suffix">元</span>
                </el-input>
              </el-form-item>
              <el-form-item label="小计" size="small" v-if="dialogType===0">
                <el-input type="number" v-model.number="teamRow.stationSubtotal">
                  <span slot="suffix">元</span>
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-form-item label="按面积核算" size="small">
            </el-form-item>
            <el-col class="other">
              <el-form-item label="照明上月读数" size="small">
                <el-input type="number" v-model.number="teamRow.illuminationBeforeMonth"
                          :disabled="dialogType==1&&teamRow.type!==3"></el-input>
              </el-form-item>
              <el-form-item label="空调" size="small" v-if="dialogType===0">
                <el-input type="number" v-model.number="teamRow.vrvFee">
                  <span slot="suffix">元</span>
                </el-input>
              </el-form-item>
              <el-form-item label="物业" size="small" v-if="dialogType===0">
                <el-input type="number" v-model.number="teamRow.tenementFee">
                  <span slot="suffix">元</span>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col class="other">
              <el-form-item label="照明本月度数" size="small">
                <el-input type="number" v-model.number="teamRow.illuminationMonth"
                          :disabled="dialogType==1&&teamRow.type!==3"></el-input>
              </el-form-item>
              <el-form-item label="水" size="small" v-if="dialogType===0">
                <el-input type="number" v-model.number="teamRow.waterFee">
                  <span slot="suffix">元</span>
                </el-input>
              </el-form-item>
              <el-form-item label="小计" size="small" v-if="dialogType===0">
                <el-input type="number" v-model.number="teamRow.areaSubtotal">
                  <span slot="suffix">元</span>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col class="other">
              <el-form-item label="照明费用" size="small" v-if="dialogType===0">
                <el-input type="number" v-model.number="teamRow.illuminationFee">
                  <span slot="suffix">元</span>
                </el-input>
              </el-form-item>
              <el-form-item label="能耗" size="small" v-if="dialogType===0">
                <el-input type="number" v-model.number="teamRow.energyFee">
                  <span slot="suffix">元</span>
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-form-item label="总计" size="small" v-if="dialogType===0">
            <el-input type="number" v-model.number="teamRow.total">
              <span slot="suffix">元</span>
            </el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="warning" size="small"  @click="submitForm('teamRow')" v-no-more-click>确定</el-button>
          <el-button size="small" @click="outerVisible = false">取消</el-button>
        </div>
      </el-dialog>
      <!--<el-button size="small" icon="el-icon-upload2">导出</el-button>-->
    </div>
    <my-table
      :data="tableData"
      :col-configs="colConfigs"
      v-loading="listLoading"
      :page-num="pageNum"
      :page-size="pageSize"
    >
      <el-table-column
        slot="opt"
        fixed="right"
        label="操作"
        width="120">
        <template slot-scope="scope">
          <el-button
            @click.native.prevent="editTeam(scope.row.tenementId)"
            type="text"
            size="small">
            修改
          </el-button>
          <el-popover
            placement="top"
            width="160"
            :ref="`popover-${scope.$index}`"
          >
            <p>确定删除这条数据吗?</p>
            <div style="text-align: right; margin: 0">
              <el-button size="mini" type="text" @click="$refs[`popover-${scope.$index}`].doClose()">取消</el-button>
              <el-button type="primary" size="mini" @click.native.prevent="deleteRow(scope)">确定</el-button>
            </div>
            <el-button type="text" size="small" slot="reference" v-popover:popover-${scope.$index}>删除</el-button>
          </el-popover>
        </template>
      </el-table-column>
    </my-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pageNum"
      :page-sizes="[10, 20, 30, 40]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
  </div>
</template>

<script>
  import {
    getList,
    addTenementDetail,
    selectTenementDetail,
    deleteTenementDetail,
    updateTenementDetail,
    selectTeam,
    selectPropertyData
  } from '@/api/propertysubsidiary'
  import myTable from '@/components/myTable'

  import { AreaSelect } from 'vue-area-linkage'
  import { pca } from 'area-data'
  import { formatDate } from '@/utils/index'

  const tenementMonth = {
    props: ['colConfig'],
    filters: {
      formatDate(time) {
        var date = new Date(time)
        return formatDate(date, 'yyyy-MM')
      }
    },
    template: `
  <el-table-column :label="colConfig.label" :width="colConfig.width" :fixed="colConfig.fixed">
      <span slot-scope="scope">
        {{ scope.row[colConfig.prop] | formatDate }}
      </span>
  </el-table-column>
  `
  }

  const configs = {
    props: ['colConfig'],
    template: `
  <el-table-column :label="colConfig.label">
            <el-table-column  v-for="(item, index) in colConfig.children"  :label="item.label" :width="item.width">
                <span slot-scope="scope" >
                    <span>{{scope.row[item.prop]}}</span>
                </span>
            </el-table-column>
  </el-table-column>
  `
  }

  export default {
    components: {
      myTable,
      AreaSelect
    },
    data() {
      return {
        colConfigs: [
          { prop: 'floorName', label: '楼层（F）', width: '100', fixed: true },
          { prop: 'teamName', label: '部门/所', width: '150', fixed: true },
          { prop: 'tenementMonth', label: '结算月份', width: '150', fixed: true, component: tenementMonth },
          { prop: 'teamCount', label: '部门人数', width: '100' },
          { prop: 'peopleCount', label: '总人数', width: '100' },
          { prop: 'companyArea', label: '总面积(㎡)', width: '100' },
          { prop: 'departmentArea', label: '部门面积(㎡)', width: '100' },
          {
            label: '房租', children: [
              { prop: 'rentPrice', label: '总费用(元)', width: '120' },
              { prop: 'rentTeamPrice', label: '部门费用(元)', width: '120' }
            ], component: configs
          },
          {
            label: '物业费', children: [
              { prop: 'tenementPrice', label: '单价(元)', width: '100' },
              { prop: 'tenementMonthPrice', label: '本月费用(元)', width: '100' }
            ], component: configs
          },
          {
            label: '能耗', children: [
              { prop: 'energyPrice', label: '单价(元)', width: '100' },
              { prop: 'energyMonthPrice', label: '本月费用(元)', width: '100' }
            ], component: configs
          },
          {
            label: '空调', children: [
              { prop: 'vrvPrice', label: '单价(元)', width: '100' },
              { prop: 'vrvMonthPrice', label: '本月费用(元)', width: '100' }
            ], component: configs
          },
          {
            label: '水', children: [
              { prop: 'waterPrice', label: '单价(元)', width: '100' },
              { prop: 'waterMonthPrice', label: '本月费用(元)', width: '100' }
            ], component: configs
          },
          {
            label: '照明电费', children: [
              { prop: 'illuminationPrice', label: '单价(元)', width: '100' },
              { prop: 'illuminationMonthPrice', label: '本月费用(元)', width: '100' }
            ], component: configs
          },
          { prop: 'pooled', label: '公摊(元)', width: '100' },
          {
            label: '11楼房租核算', children: [
              { prop: 'roomPrice', label: '单间单价(元)', width: '100' },
              { prop: 'roomCount', label: '数量', width: '100' },
              { prop: 'roomSubtotal', label: '小计(元)', width: '100' },
              { prop: 'stationPrice', label: '工位单价(元)', width: '100' },
              { prop: 'stationCount', label: '数量', width: '100' },
              { prop: 'stationSubtotal', label: '小计(元)', width: '100' },
              { prop: 'rentTotal', label: '合计(元)', width: '100' }
            ], component: configs
          },
          {
            label: '按面积核算', children: [
              { prop: 'illuminationBeforeMonth', label: '照明上月读数', width: '120' },
              { prop: 'illuminationMonth', label: '照明本月度数', width: '120' },
              { prop: 'illuminationFee', label: '照明费用(元)', width: '100' },
              { prop: 'vrvFee', label: '空调(元)', width: '100' },
              { prop: 'waterFee', label: '水(元)', width: '100' },
              { prop: 'energyFee', label: '能耗(元)', width: '100' },
              { prop: 'tenementFee', label: '物业(元)', width: '100' },
              { prop: 'areaSubtotal', label: '小计(元)', width: '100' }
            ], component: configs
          },
          { prop: 'total', label: '总计(元)', width: '100' },
          { slot: 'opt' }
        ],
        noConfigs: [
          { prop: 'floorName', label: '楼层（F）', width: '100', fixed: true },
          { prop: 'teamName', label: '部门/所', width: '150', fixed: true },
          {
            label: '房租', children: [
              { prop: 'rentTeamPrice', label: '部门费用(元)', width: '120' }
            ], component: configs
          },
          {
            label: '11楼房租核算', children: [
              { prop: 'roomPrice', label: '单间单价(元)', width: '100' },
              { prop: 'roomCount', label: '数量', width: '100' },
              { prop: 'stationPrice', label: '工位单价(元)', width: '100' },
              { prop: 'stationCount', label: '数量', width: '100' },
              { prop: 'rentTotal', label: '合计(元)', width: '100' }
            ], component: configs
          },
          {
            label: '按面积核算', children: [
              { prop: 'illuminationFee', label: '照明费用(元)', width: '100' },
              { prop: 'vrvFee', label: '空调(元)', width: '100' },
              { prop: 'waterFee', label: '水(元)', width: '100' },
              { prop: 'energyFee', label: '能耗(元)', width: '100' },
              { prop: 'tenementFee', label: '物业(元)', width: '100' }
            ], component: configs
          },
          { prop: 'total', label: '总计(元)', width: '100' }
        ],
        searchForm: {},
        searchFormList: {},
        professions: [],
        typeNames: [],
        listLoading: true,
        dialogTitle: '新增物业费用明细',
        dialogType: 0,
        teamRow: {},
        teamRowClear: {},
        tableData: [],
        pageNum: 1,
        pageSize: 10,
        total: 1,
        outerVisible: false,
        pca: pca,
        rules: {
          teamName: [
            { required: true, message: '请输入部门/所', trigger: 'change' }
          ]
        },
        visible: false,
        propertyData: [],
        typeList: [
          { value: 1, label: '按固定房租核算' },
          { value: 2, label: '按人头分摊核算' },
          { value: 3, label: '按面积分摊核算' }
        ]
      }
    },
    created() {
      this.teamRowClear = JSON.parse(JSON.stringify(this.teamRow))
      this.fetchData()
    },
    computed: {
      roleType() {
        return this.$store.state.user.roleType
      }
    },
    methods: {
      fetchData() {
        this.searchFormList.pageNum = this.pageNum
        this.searchFormList.pageSize = this.pageSize
        this.listLoading = true
        getList(this.searchFormList).then(response => {
          this.tableData = response.responseBody.list
          this.total = response.responseBody.total
          this.listLoading = false
        })
      },
      selectPropertyData() {
        selectPropertyData().then(response => {
          this.propertyData = response.responseBody
          this.propertyData.forEach(value => {
            if (value.name === '工位(房租)') {
              this.$set(this.teamRow, 'stationPrice', value.unitPrice)
            }
            if (value.name === '单间(房租)') {
              this.$set(this.teamRow, 'roomPrice', value.unitPrice)
            }
          })
        })
      },
      search() {
        this.pageNum = 1
        this.searchFormList = JSON.parse(JSON.stringify(this.searchForm))
        this.fetchData()
      },
      addTeam() {
        if (this.$refs['teamRow']) {
          this.$refs['teamRow'].resetFields()
        }
        this.outerVisible = true
        this.dialogTitle = '新增物业费用明细'
        this.teamRow = JSON.parse(JSON.stringify(this.teamRowClear))
        this.dialogType = 1
        this.selectPropertyData()
      },
      editTeam(tenementId) {
        if (this.$refs['teamRow']) {
          this.$refs['teamRow'].resetFields()
        }
        this.outerVisible = true
        this.dialogTitle = '修改物业费用明细'
        this.teamRow = JSON.parse(JSON.stringify(this.teamRowClear))
        this.dialogType = 0
        const params = {
          tenementId: tenementId
        }
        selectTenementDetail(params).then(response => {
          this.teamRow = response.responseBody
          this.teamRow.beforeTotal = this.teamRow.total
          this.selectPropertyData()
        })
      },
      submitForm(formName) {
        const params = {
          floorName: this.teamRow.floorName || '',
          teamId: this.teamRow.teamId,
          teamName: this.teamRow.teamName || '',
          tenementMonth: this.teamRow.tenementMonth || '',
          teamCount: this.teamRow.teamCount || 0,
          peopleCount: this.teamRow.peopleCount || 0,
          companyArea: this.teamRow.companyArea || 0,
          rentPrice: this.teamRow.rentPrice || 0,
          tenementPrice: this.teamRow.tenementPrice || 0,
          tenementMonthPrice: this.teamRow.tenementMonthPrice || 0,
          energyPrice: this.teamRow.energyPrice || 0,
          energyMonthPrice: this.teamRow.energyMonthPrice || 0,
          vrvPrice: this.teamRow.vrvPrice || 0,
          vrvMonthPrice: this.teamRow.vrvMonthPrice || 0,
          waterPrice: this.teamRow.waterPrice || 0,
          waterMonthPrice: this.teamRow.waterMonthPrice || 0,
          illuminationPrice: this.teamRow.illuminationPrice || 0,
          illuminationMonthPrice: this.teamRow.illuminationMonthPrice || 0,
          pooled: this.teamRow.pooled || 0
        }
        if (this.dialogType) {
          params.type = this.teamRow.type
          if (this.teamRow.type === 1) {
            params.roomPrice = this.teamRow.roomPrice || 0
            params.roomCount = this.teamRow.roomCount || 0
            params.stationPrice = this.teamRow.stationPrice || 0
            params.stationCount = this.teamRow.stationCount || 0
          } else if (this.teamRow.type === 2) {
            params.roomPrice = this.teamRow.roomPrice || 0
          } else {
            params.departmentArea = this.teamRow.departmentArea || 0
            params.illuminationBeforeMonth = this.teamRow.illuminationBeforeMonth || ''
            params.illuminationMonth = this.teamRow.illuminationMonth || ''
          }
        } else {
          params.roomPrice = this.teamRow.roomPrice || 0
          params.roomCount = this.teamRow.roomCount || 0
          params.stationPrice = this.teamRow.stationPrice || 0
          params.stationCount = this.teamRow.stationCount || 0
          params.departmentArea = this.teamRow.departmentArea || 0

          params.rentTeamPrice = this.teamRow.rentTeamPrice || 0
          params.tenementId = this.teamRow.tenementId
          params.beforeTotal = this.teamRow.beforeTotal
          params.roomSubtotal = this.teamRow.roomSubtotal || 0
          params.stationSubtotal = this.teamRow.stationSubtotal || 0
          params.rentTotal = this.teamRow.rentTotal || 0
          params.illuminationBeforeMonth = this.teamRow.illuminationBeforeMonth || ''
          params.illuminationMonth = this.teamRow.illuminationMonth || ''
          params.illuminationFee = this.teamRow.illuminationFee || 0
          params.vrvFee = this.teamRow.vrvFee || 0
          params.waterFee = this.teamRow.waterFee || 0
          params.energyFee = this.teamRow.energyFee || 0
          params.tenementFee = this.teamRow.tenementFee || 0
          params.areaSubtotal = this.teamRow.areaSubtotal || 0
          params.total = this.teamRow.total || 0
        }
        if (this.teamRow.teamId) {
          this.$refs[formName].validate((valid) => {
            if (valid) {
              if (this.dialogType) {
                addTenementDetail(params).then(response => {
                  this.outerVisible = false
                  this.fetchData()
                })
              } else {
                updateTenementDetail(params).then(response => {
                  this.outerVisible = false
                  this.fetchData()
                })
              }
            } else {
              console.log('error submit!!')
              return false
            }
          })
        } else {
          this.$message({
            message: '该部门不存在',
            type: 'warning'
          })
        }
      },
      deleteRow(scope) {
        console.log(this.$refs[`popover-${scope.$index}`])
        this.$refs[`popover-${scope.$index}`].doClose()
        const params = {
          tenementId: scope.row.tenementId,
          teamId: scope.row.teamId,
          total: scope.row.total,
          tenementMonth: scope.row.tenementMonth,
          isDel: 1
        }
        deleteTenementDetail(params).then(response => {
          this.fetchData()
        })
      },
      handleSizeChange(val) {
        this.pageSize = val
        this.fetchData()
      },
      handleCurrentChange(val) {
        this.pageNum = val
        this.fetchData()
      },
      addressChange() {
        this.teamRow.provinceId = this.teamRow.addressId[0]
        this.teamRow.cityId = this.teamRow.addressId[1]
        this.teamRow.address = this.pca[86][this.teamRow.addressId[0]] + this.pca[this.teamRow.addressId[0]][this.teamRow.addressId[1]]
      },
      querySearchFloor(queryString, callback) {
        // queryString 为在框中输入的值
        // callback 回调函数,将处理好的数据推回
        const propertyData = []
        let arr = []
        this.propertyData.forEach(value => {
          if (value.name.indexOf('面积') >= 0) {
            propertyData.push(value)
          }
        })
        propertyData.forEach(value => {
          if (value.name.indexOf(queryString) >= 0) {
            arr.push(value)
          }
        })
        for (const i of arr) {
          i.value = i.name
        }
        if (arr.length === 0) {
          arr = [{ value: '暂无数据' }]
        }
        callback(arr)
      },
      handleSelectFloor(item) {
        this.$set(this.teamRow, 'floorName', item.name)
        this.$set(this.teamRow, 'companyArea', item.area)
        if (item.name.indexOf('科锐') >= 0) {
          this.propertyData.forEach(value => {
            if (value.name === '科锐物业费') {
              this.$set(this.teamRow, 'tenementPrice', value.unitPrice)
            }
            if (value.name === '科锐能耗费') {
              this.$set(this.teamRow, 'energyPrice', value.unitPrice)
            }
            if (value.name === '科锐空调费') {
              this.$set(this.teamRow, 'vrvPrice', value.unitPrice)
            }
            if (value.name === '科锐电费') {
              this.$set(this.teamRow, 'illuminationPrice', value.unitPrice)
            }
            if (value.name === '科锐水费') {
              this.$set(this.teamRow, 'waterPrice', value.unitPrice)
            }
            if (value.name === '房租(科锐)') {
              this.$set(this.teamRow, 'rentPrice', value.unitPrice)
            }
          })
        } else {
          this.propertyData.forEach(value => {
            if (value.name === '11楼物业费') {
              this.$set(this.teamRow, 'tenementPrice', value.unitPrice)
            }
            if (value.name === '11楼能耗费') {
              this.$set(this.teamRow, 'energyPrice', value.unitPrice)
            }
            if (value.name === '11楼空调费') {
              this.$set(this.teamRow, 'vrvPrice', value.unitPrice)
            }
            if (value.name === '11楼电费') {
              this.$set(this.teamRow, 'illuminationPrice', value.unitPrice)
            }
            if (value.name === '11楼水费') {
              this.$set(this.teamRow, 'waterPrice', value.unitPrice)
            }
            if (value.name === '房租(总部)') {
              this.$set(this.teamRow, 'rentPrice', value.unitPrice)
            }
          })
        }
      },
      querySearchTeam(queryString, callback) {
        // queryString 为在框中输入的值
        // callback 回调函数,将处理好的数据推回
        delete this.teamRow.teamId
        if (queryString) {
          const params = {
            teamName: queryString
          }
          selectTeam(params).then(response => {
            for (const i of response.responseBody) {
              i.value = i.teamName
            }
            let nameList = response.responseBody
            if (nameList.length === 0) {
              nameList = [{ value: '暂无数据' }]
            }
            callback(nameList)
          })
        } else {
          callback([])
        }
      },
      handleSelectTeam(item) {
        this.$set(this.teamRow, 'teamId', item.teamId)
        this.$set(this.teamRow, 'teamName', item.teamName)
        this.$set(this.teamRow, 'teamCount', item.teamCount)
        this.$set(this.teamRow, 'departmentArea', item.departmentArea)
      }
    },
    mounted() {
      console.log(this.pca)
    }
  }
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .app-container {
    .el-pagination {
      margin-top: 20px;
    }
    .table-btn {
      margin-bottom: 10px;
      & > button {
        margin: 0 20px;
      }
      .el-dialog {
        textarea {
          margin-top: 10px;
        }
        .el-checkbox {
          margin-right: 20px;
        }
        .el-checkbox + .el-checkbox {
          margin-left: 0;
        }
      }
    }
  }

</style>


<style rel="stylesheet/scss" lang="scss">
  .el-input__icon {
    line-height: 100%;
  }

  .el-form-item__content {
    line-height: 33px;
  }

  .area-select .area-selected-trigger {
    padding: 0 10px;
  }

  /*.el-table__body tr.hover-row>td {
    background-color: #0000ff !important;
  }

  .el-table__body tr.current-row>td {
    background-color: #0000ff !important;
  }*/
</style>
